/*
 * Copyright (C) 2021 Fastjrun, Inc. All Rights Reserved.
 */
package com.fastjrun.share.demo.security.vo;

import com.fastjrun.share.demo.entity.SysUser;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

@Data
public class UserDetailsVO implements UserDetails {

    private SysUser sysUser;
    private Collection<? extends GrantedAuthority> authorities;

    @Override
    public String getPassword() {
        return sysUser.getPassword();
    }

    @Override
    public String getUsername() {
        return sysUser.getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return sysUser.getIsAccountNonExpired()==1;
    }

    @Override
    public boolean isAccountNonLocked() {
        return sysUser.getIsAccountNonLocked()==1;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return sysUser.getIsCredentialsNonExpired()==1;
    }

    @Override
    public boolean isEnabled() {
        return sysUser.getIsEnabled()==1;
    }
}
